package cn.mesmile.design.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zb
 * @version 1.0
 * @date 2020/11/21 12:07
 * @description
 */
public class WebSiteFactory {

    private Map<String,ConcreteWebSite> map = new HashMap<>();

    /**
     *  根据key 获取分类站点
     * @param category
     * @return
     */
    public CloudWebSite getWebSite (String category) {
        if (map.containsKey(category)) {
            ConcreteWebSite concreteWebSite = map.get(category);
            return concreteWebSite;
        } else {
            ConcreteWebSite concreteWebSite = new ConcreteWebSite(category);
            map.put(category,concreteWebSite);
            return concreteWebSite;
        }
    }

    public int getWebSiteSize() {
        return map.size();
    }

}
